package com.example;

public class ThreadCreateByInherit {

    public static class TestThread extends Thread{

        public TestThread(String name) {
            super(name);
        }

        @Override
        public void run() {

            while (!this.isInterrupted()){
                System.out.println("我是" + this.getName());
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        TestThread thread = new TestThread("test-thread");
        thread.start();
        Thread.sleep(1000*10);
        thread.interrupt();
    }
}
